package com.fh.service.ccode;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.james.mime4j.field.datetime.DateTime;
import org.springframework.stereotype.Service;

import com.fh.dao.DaoSupport;
import com.fh.util.AliSmsUtil;
import com.fh.util.PageData;
import com.fh.util.Tools;
import com.taobao.api.ApiException;

import oracle.net.aso.d;

@Service("appCcodeUserService")
public class AppCcodeUserService {
	
	@Resource(name = "daoSupport")
	private DaoSupport dao;
	
	/*
	* 验证码判断
	*/
	// 查找验证码,参数phoneNum
	public PageData findValidateCode(PageData pd) throws Exception{
		return (PageData)dao.findForObject("AppUserMapper.getPhoneCode", pd);
	}
	// 插入验证码,参数phoneNum,code
	public void insertValidateCode(PageData pd) throws Exception{
		dao.save("AppUserMapper.addPhoneCode", pd);
	}
	// 更新验证码,参数phoneNum,code
	public void updateValidateCode(PageData pd) throws Exception{
		dao.update("AppUserMapper.updatePhoneCode", pd);
	}
	
	
	// 修改密码
	public void changePassword(PageData pd) throws Exception{
		dao.update("AppUserMapper.updatePassword", pd);
	}
	
	// 找到手机对应的用户是否存在
	public boolean existUserWithPhone(PageData pd)	throws Exception{
		if((PageData)dao.findForObject("AppUserMapper.existUserWithPhone", pd) == null){
			return false;
		}
		return true;
	}
	
	/*
	* 登录判断
	*/
	public PageData getUserByNameAndPwd(PageData pd)throws Exception{
		return (PageData)dao.findForObject("AppUserMapper.getUserInfoByNameAndPwd", pd);
	}
	
	public PageData findInfoByName(PageData pd)throws Exception{
		return (PageData)dao.findForObject("AppUserMapper.findInfoByName", pd);
	}
	
	public PageData findInfoByEmail(PageData pd)throws Exception{
		return (PageData)dao.findForObject("AppUserMapper.findInfoByEmail", pd);
	}
	
	public PageData findInfoByPhone(PageData pd)throws Exception{
		return (PageData)dao.findForObject("AppUserMapper.findInfoByPhone", pd);
	}
	
	public void saveRegisterInfo(PageData pd)throws Exception{
		dao.save("AppUserMapper.saveAppUser", pd);
	}

	public void updateToken(PageData pd) throws Exception{
		dao.update("AppUserMapper.updateToken", pd);
	}

	public PageData getInfoByToken(PageData pd) throws Exception{
		return (PageData) dao.findForObject("AppUserMapper.findInfoByToken", pd);
		
	}

}
